package com.gzy.wb.repository;

import com.gzy.wb.model.MyLog;
import com.gzy.wb.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

// T  操作的是哪个模型
// ID  模型的 主键的 数据类型
public interface MyLogRepository extends JpaRepository<MyLog, Long> {


//    List<MyLog> findAllByUid(Integer id);
    List<MyLog> findAllByUserid(Integer id);

    // ASC  DESC
//    @Query(value="select * from my_log where userid = ? limit  ? , ? order by create_at DESC",nativeQuery=true)
    @Query(value="select * from my_log where userid = ? order by create_at DESC limit  ? , ?",nativeQuery=true)
    List<MyLog> pageWhere(Integer uid,Long offset,Long size);

    @Query(value="select count(*) from my_log where userid = ?",nativeQuery=true)
    long countByUser(Integer id);
}
